<div class="nodesSort">
<?php foreach (array('all' => _('List all'), 'top' => _('List top level')) as $select_key => $select_label):?>
<?php   if ($select_key == @$requested_select):?>
  <span class="nodesSortCurrent"><?php _h($select_label);?></span> |
<?php   else:?>
<?php link_to_remote($select_label, 'xigg-admin-category-list', array('base' => '/category/list', 'params' => array('select' => $select_key)));?>
  |
<?php   endif;?>
<?php endforeach;?>
</div>

<table>
  <thead>
    <tr>
      <th class="left"><?php _e('Name');?></th>
      <th class="left"><?php _e('Description');?></th>
      <th><?php _e('Articles');?></th>
      <th><?php _e('Action');?></th>
    </tr>
  </thead>
  <tfoot>
    <tr><td colspan="4"></td></tr>
  </tfoot>
  <tbody>
<?php while ($e =& $entity_objects->getNext()):?>
    <tr>
      <td class="left"><a href="<?php echo Sabai_URL::getByScript('index.php', '/', array('category_id' => $e->getId()));?>"><?php _h(Sabai_I18N::strcutMore($e->getLabel(), 50));?></a></td>
      <td class="left"><?php _h(Sabai_I18N::strcutMore($e->get('description'), 250));?></td>
      <td><?php echo $e->getNodeCount();?></td>
      <td><?php link_to_remote(_('Edit'), 'xigg-admin-category-list-update', array('base' => '/category/' . $e->getId() . '/edit'));?> <?php link_to_remote(_('Delete'), 'xigg-admin-category-list-update', array('base' => '/category/' . $e->getId() . '/delete'));?></td>
    </tr>
<?php   if (isset($child_categories[$e->getId()])):?>
<?php     while($child =& $child_categories[$e->getId()]->getNext()):?>
    <tr>
      <td class="left"><?php echo str_repeat('&raquo; ', $child->parentsCount());?><a href="<?php echo Sabai_URL::getByScript('index.php', '/', array('category_id' => $child->getId()));?>"><?php _h(Sabai_I18N::strcutMore($child->getLabel(), 50));?></a></td>
      <td class="left"><?php _h(Sabai_I18N::strcutMore($child->get('description'), 250));?></td>
      <td><?php echo $child->getNodeCount();?></td>
      <td><?php link_to_remote(_('Edit'), 'xigg-admin-category-list-update', array('base' => '/category/' . $child->getId() . '/edit'));?> <?php link_to_remote(_('Delete'), 'xigg-admin-category-list-update', array('base' => '/category/' . $child->getId() . '/delete'));?></td>
    </tr>
<?php     endwhile;?>
<?php   endif;?>
<?php endwhile; ?>
  </tbody>
</table>

<div class="addEntityLink">
  <?php link_to_remote(_('Add category'), 'xigg-admin-category-list-update', array('base' => '/category/add'));?>
</div>

<div id="xigg-admin-category-list-update">
</div>
